package modelo.bean;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name="aluguel")
public class Aluguel extends BeanGenerica{

	@Id
	@GeneratedValue
	@Column(name="id_aluguel", nullable=false)
	private Integer idAluguel;
	
	@Column(name="dt_aluguel", nullable=false)
	@Temporal(TemporalType.DATE)
	private Date dtAluguel;
	
	@Column(name="dt_devolucao", nullable=false)
	@Temporal(TemporalType.DATE)
	private Date dtDevolucao;
	
	@Column(name="dt_aluguel", nullable=false)
	private String csStatus;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="fk_cliente", insertable=true, updatable=true, nullable=false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Cliente cliente;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="fk_usuario", insertable=true, updatable=true, nullable=false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Usuario usuario;
	
	public Integer getIdAluguel() {
		return idAluguel;
	}
	public void setIdAluguel(Integer idAluguel) {
		this.idAluguel = idAluguel;
	}
	public Date getDtAluguel() {
		return dtAluguel;
	}
	public void setDtAluguel(Date dtAluguel) {
		this.dtAluguel = dtAluguel;
	}
	public Date getDtDevolucao() {
		return dtDevolucao;
	}
	public void setDtDevolucao(Date dtDevolucao) {
		this.dtDevolucao = dtDevolucao;
	}
	public String getCsStatus() {
		return csStatus;
	}
	public void setCsStatus(String csStatus) {
		this.csStatus = csStatus;
	}
	public Cliente getCliente() {
		return cliente;
	}
	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}
	public Usuario getUsuario() {
		return usuario;
	}
	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}
}
